package com.carey.yygh.hosp.controller;

import com.carey.yygh.cmn.client.DictFeignClient;
import com.carey.yygh.common.result.Result;
import com.carey.yygh.hosp.service.HospitalService;
import com.carey.yygh.model.cmn.Dict;
import com.carey.yygh.model.hosp.Hospital;
import com.carey.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "医院信息")
@RestController
//@CrossOrigin
@RequestMapping("admin/hosp/hospital")
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;

    @Autowired
    private DictFeignClient dictFeignClient;

    //条件查询带分页
    @ApiOperation("分页条件查询")
    @GetMapping("list/{current}/{limit}")
    public Result listHosp(@PathVariable("current") Integer current,
                           @PathVariable("limit") Integer limit, HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pages = hospitalService.listHosp(current,limit,hospitalQueryVo);
        return Result.ok(pages);
    }

    @ApiOperation("更新医院上线状态")
    @GetMapping("updateStatus/{id}/{status}")
    public Result updateStatus(@PathVariable("id") String id,
                               @PathVariable("status") Integer status){
        //医院信息保存在mongodb中
        hospitalService.updateStatus(id,status);
        return Result.ok();
    }

    @ApiOperation("获取医院详情")
    @GetMapping("show/{id}")
    public Result show(@PathVariable String id){
        Map<String,Object> map = hospitalService.show(id);
        return Result.ok(map);
    }

}
